package JVM.oom;

public class UnableCreateNewThreadDemo {
    // 在Linux运行，Windows没有默认限制线程数，会撑爆

    // Exception in thread "main" java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
    public static void main(String[] args) {

        for (int i = 0;  ; i++) {

            System.out.println("******* i = " + i);

            new Thread(()->{
                try {
                    Thread.sleep(Integer.MAX_VALUE);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }, String.valueOf(i)).start();
        }
    }
}
